package com.cn.kabalifemerchants.view.dialogView;//package com.cn.automobileservice.view.dialogView;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.cn.kabalifemerchants.R;
import com.cn.kabalifemerchants.ui.login.AgreementActivity;

/**
 * Created by 晓林 on 2019/10/18.
 * function: 首页
 */
public class AgreementDialog extends Dialog {
    protected Context mContext;

    protected WindowManager.LayoutParams mLayoutParams;

    TextView tv_btn_y, tv_btn_n;
    TextView tv_dialog_privacy_agreement, tv_dialog_user_agreement;


    public TextView getTv_btn_y() {
        return tv_btn_y;
    }

    public TextView getTv_btn_n() {
        return tv_btn_n;
    }

    public AgreementDialog(Context context) {
        super(context);
        initView(context);
    }

    public AgreementDialog(Activity context) {
        super(context);
        initView(context);
    }


    private void initView(Context context) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setBackgroundDrawableResource(R.drawable.transparent_bg);
        mContext = context;
        Window window = this.getWindow();
        mLayoutParams = window.getAttributes();
        mLayoutParams.alpha = 1f;
        window.setAttributes(mLayoutParams);
        if (mLayoutParams != null) {
            mLayoutParams.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
            mLayoutParams.gravity = Gravity.CENTER;
        }
        View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_agreement, null);

        tv_btn_n = dialogView.findViewById(R.id.tv_btn_n);
        tv_btn_y = dialogView.findViewById(R.id.tv_btn_y);

        tv_dialog_privacy_agreement = dialogView.findViewById(R.id.tv_dialog_privacy_agreement);
        tv_dialog_user_agreement = dialogView.findViewById(R.id.tv_dialog_user_agreement);

        tv_dialog_privacy_agreement.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, AgreementActivity.class);
                Bundle bundle = new Bundle();
                bundle.putInt("sign", 5);
                intent.putExtras(bundle);
                mContext.startActivity(intent);
            }
        });

        tv_dialog_user_agreement.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, AgreementActivity.class);
                Bundle bundle = new Bundle();
                bundle.putInt("sign", 1);
                intent.putExtras(bundle);
                mContext.startActivity(intent);
            }
        });

        setContentView(dialogView);

    }
}
